/*
 * Filename    : State_Activity.java
 * Projectname : RamaShinta
 * Date        : Nov 17, 2012 , 12:09:33 PM 
 * 
 * Super Class
 */

package com.amikomgamedev.ramashinta.state;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.camera.hud.HUD;
import org.andengine.engine.handler.IUpdateHandler;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.IOnAreaTouchListener;
import org.andengine.entity.scene.ITouchArea;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.ButtonSprite;
import org.andengine.entity.sprite.ButtonSprite.OnClickListener;
import org.andengine.entity.util.FPSLogger;
import org.andengine.input.touch.TouchEvent;
import org.andengine.input.touch.controller.MultiTouch;
import org.andengine.input.touch.controller.MultiTouchController;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import android.view.KeyEvent;

import com.amikomgamedev.ramashinta.game.Game_Data;
import com.amikomgamedev.ramashinta.game.Game_Define;
import com.amikomgamedev.ramashinta.graphic.Graphic_Detach;
import com.amikomgamedev.ramashinta.sound.Sound_Manager;
import com.amikomgamedev.ramashinta.text.Text_Manager;

public class State_Activity extends SimpleBaseGameActivity implements IUpdateHandler, Game_Define, Game_Data,
		IOnAreaTouchListener, OnClickListener
{

	// list state
	protected static final byte				STATE_LOGO				= 0;
	protected static final byte				STATE_MENU_MAIN			= 1;
	protected static final byte				STATE_MENU_CREDIT		= 2;
	protected static final byte				STATE_MENU_HELP			= 3;
	protected static final byte				STATE_GAME_PLAY			= 4;
	protected static final byte				STATE_GAME_OVER			= 5;
	protected static final byte				STATE_GAME_PAUSE		= 6;
	protected static final byte				STATE_GAME_WIN			= 7;
	protected static final byte				STATE_LOADING_SCREEN	= 8;
	protected static final byte				STATE_MENU_OPTION		= 9;
	protected static final byte				STATE_MENU_LEVEL		= 10;
	protected byte							State_Menu_Current		= -1;

	protected Camera						m_Camera;
	protected Scene							m_Scene					= new Scene();
	protected HUD							m_Hud					= new HUD();
	protected OnClickListener				m_Click;

	// instance class graphic
	protected Graphic_Detach				graphic					= new Graphic_Detach(this, m_Scene, m_Hud,
																			m_Camera, m_Click);
	// instance class Text
	protected Text_Manager					text					= new Text_Manager(this, m_Scene, m_Hud, graphic);
	// instance class Sound
	protected Sound_Manager					sound					= new Sound_Manager(this);

	public static SimpleBaseGameActivity	activity;

	@Override
	public EngineOptions onCreateEngineOptions()
	{
		activity = this;

		m_Camera = new Camera(0, 0, RES_WIDTH, RES_HEIGHT);
		m_Camera.setHUD(m_Hud);

		EngineOptions en = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
				RES_WIDTH, RES_HEIGHT), m_Camera);

		en.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);

		return en;
	}

	@Override
	protected void onCreateResources()
	{
		// TODO Auto-generated method stub

	}

	@Override
	protected Scene onCreateScene()
	{		
		if(MultiTouch.isSupported(activity))
			mEngine.setTouchController(new MultiTouchController());
		
		mEngine.registerUpdateHandler(new FPSLogger());
		mEngine.registerUpdateHandler(this);

		m_Scene.setOnAreaTouchListener(this);
		return m_Scene;
	}

	@Override
	public void onUpdate(float pSecondsElapsed)
	{
		// TODO Auto-generated method stub
	}

	@Override
	public void reset()
	{
		// TODO Auto-generated method stub

	}

	protected void switchState(byte state)
	{

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onKeyUp(int keyCode, KeyEvent event)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX,
			float pTouchAreaLocalY)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY)
	{

	}

	@Override
	public synchronized void onResumeGame()
	{
		// TODO Auto-generated method stub
		super.onResumeGame();
	}

	@Override
	public synchronized void onPauseGame()
	{
		// TODO Auto-generated method stub
		super.onPauseGame();
	}

}
